package common.system;

public class ProcessManager
{

	private String description;
	private ProcessRunner process;
	private Thread thread;

	public ProcessManager()
	{
		super();
	}

	public void execute(String command, String description)
	{
		this.description = description;
		process = new ProcessRunner(command);
		thread = new Thread(process);
		thread.start();
	}

	public String getOutputFrom(int position)
	{
		return process.getOutput().substring(position);
	}

	public String getError()
	{
		return process.getError();
	}

	public boolean isRunning()
	{
		return thread != null && thread.isAlive();
	}

	public String getDescription()
	{
		return description;
	}

	public int getExitCode()
	{
		return process.getExitCode();
	}
}
